// eslint-disable-next-line strict
const Controller = require('egg').Controller;

class LoginController extends Controller {
  async login() {
    try {
      const username = this.ctx.request.body.username;
      const token = this.ctx.app.jwt.sign({
        username,
      }, this.ctx.app.config.jwt.sercet);
      this.ctx.body = {
        code: '20000',
        token,
      };
    } catch (e) {
      this.ctx.body = {
        code: 40000,
        msg: '登录失败',
      };
    }

  }
}

module.exports = LoginController;
